//
//  Person.m
//  OC2_实例变量可见度_方法
//
//  Created by Scott on 16/2/26.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "Person.h"

@implementation Person


#pragma mark - setter, getter
- (void)setName:(NSString *)name {
    
    _name = name;
    
}
- (NSString *)name {
    return _name;
}


#pragma mark - init
- (instancetype)initWithName:(NSString *)name sex:(NSString *)sex age:(NSInteger)age {
    
    self = [super init];
    if (self) {
        
        _name = name;
        _age = age;
        _sex = sex;
    }
    return self;
}


#pragma mark - 构造器
+ (instancetype)person {
    
    // 1. alloc, init
    Person *per = [[Person alloc] init];
    
    // 2. 返回创建出来的对象
    return per;
}

+ (instancetype)personWithName:(NSString *)name sex:(NSString *)sex age:(NSInteger)age {
    
    // 实例变量赋值
    Person *per = [[Person alloc] initWithName:name sex:sex age:age];
    
    return per;
}





#pragma mark - other
- (void)sayHi {
    NSLog(@"hi");
}











@end
